function PageBase(menubarId, navigatorId, idx, lang) {
  this._menubar = document.getElementById(menubarId);
  this._navigator = document.getElementById(navigatorId);
  this._idx = idx;
  this._lang = lang;

  this._createElement();
};

PageBase.prototype._createElement = function() {
  var idx, m1, m2, m3, a, tr, td, _self = this;
  DOMUtils.removeChildElements(this._menubar);

  var table = document.createElement('table');
  table.className = 'navtable';
  var menus = PageBase.getMenus();
  for (var i = 0, il = menus.length; i < il; i++) {
    m1 = menus[i];
    a = document.createElement('a');
    a.className = 'main_menu';
    if (this._idx == m1.idx) {
      a.className += ' selected';
    }
    a.setAttribute('href', '#');
    a.appendChild(document.createTextNode((this._lang == 'cn') ? m1.cn : m1.en));
    a._idx = m1.idx;
    a.onclick = function() { _self._setIdx.call(_self, this._idx);
                             return false;
                           };
    tr = table.insertRow(-1);
    td = tr.insertCell(-1);
    td.appendChild(a);
    idx = this._idx.substring(0, 1);
    if (idx == m1.idx) {
      this._setNavigator([m1]);
      for (var j = 0, jl = m1.submenus.length; j < jl; j++) {
        m2 = m1.submenus[j];
        a = document.createElement('a');
        a.className = 'main_menu';
        if (this._idx == m2.idx) {
          a.className += ' selected';
        }
        a.setAttribute('href', '#');
        a.appendChild(document.createTextNode((this._lang == 'cn') ? m2.cn : m2.en));
        a._idx = m2.idx;
        a.onclick = function() { _self._setIdx.call(_self, this._idx); 
                                 return  false;
                               };
        tr = table.insertRow(-1);
        td = tr.insertCell(-1);
        td.style.padding = '0 0 0 15px';
        td.appendChild(a);

        idx = this._idx.substring(0, 2);
        if (idx == m2.idx) {
          this._setNavigator([m1, m2]);
          for (var k = 0, kl = m2.submenus.length; k < kl; k++) {
            m3 = m2.submenus[k];
            a = document.createElement('a');
            a.className = 'main_menu';
            if (this._idx == m3.idx) {
              this._setNavigator([m1, m2, m3]);
              a.className += ' selected';
            }
            a.setAttribute('href', '#');
            a.appendChild(document.createTextNode((this._lang == 'cn') ? m3.cn : m3.en));
            a._idx = m3.idx;
            a.onclick = function() { _self._setIdx.call(_self, this._idx);
                                     return false;
                                   };
            tr = table.insertRow(-1);
            td = tr.insertCell(-1);
            td.style.padding = '0 0 0 30px';
            td.appendChild(a);
          }
        }
      }
    }
  }
  this._menubar.appendChild(table);
};

PageBase.prototype._setNavigator = function(menus) {
  var m, a, _self = this;

  DOMUtils.removeChildElements(this._navigator);

  a = document.createElement('a');
  a.style.margin = '0 5px';
  a.href = '#';
  a.onclick = function() { _self._setIdx.call(_self, 0);
                           return false;
                         };
  a.appendChild(document.createTextNode((this._lang == 'cn') ? '主页' : 'Home'));
  this._navigator.appendChild(a);
  this._navigator.appendChild(document.createTextNode('>'));

  for (var i = 0, il = menus.length; i < il; i++) {
    m = menus[i];
    a = document.createElement('a');
    a.style.margin = '0 5px';
    a.href = '#';
    a._m = m;
    a.onclick = function() { _self._setIdx.call(_self, this._m.idx);
                             return false;
                           };
    a.appendChild(document.createTextNode((this._lang == 'cn') ? m.cn : m.en));
    this._navigator.appendChild(a);
    if (i < (menus.length - 1)) {
      this._navigator.appendChild(document.createTextNode('>'));
    }
  }
};

PageBase.prototype._setIdx = function(idx) {
  window.location = '{{$smarty.const.PAGE|escape:'javascript'}}?idx=' + idx + '&lang=' + this._lang; 
};

PageBase.getMenus = function() {
  return [ { idx: 1, cn: '学院简介', en: 'Home',
             submenus: [ { idx: 11, cn: '学院的价值标准', en: 'NZIOS Values',
                           submenus: [ {{*/*{ idx: 111, cn: '互信', en: 'Trust', submenus: [] },
                                       { idx: 112, cn: '互爱', en: 'Care', submenus: [] },
                                       { idx: 113, cn: '交流', en: 'Communication', submenus: [] },
                                       { idx: 114, cn: '预备', en: 'Preparation', submenus: [] },
                                       { idx: 115, cn: '成功', en: 'Success', submenus: [] }*/*}}] },
                         {{*/*{ idx: 12, cn: '学院的历史', en: 'History', submenus: [] },
                         { idx: 13, cn: '我们的教师', en: 'Lecturers', submenus: [] },
                         { idx: 14, cn: '我们的学生', en: 'Students', submenus: [] },
                         { idx: 15, cn: '校友', en: 'Alumni', submenus: [] },*/*}}
                         { idx: 16, cn: '就业移民', en: 'Jobs and immigration', submenus: [] }{{*/*,
                         { idx: 17, cn: '您的权利与义务', en: 'Right And Obligation', submenus: [] }*/*}} ] },

           { idx: 2, cn: '为何选择NZIOS', en: 'About us',
             submenus: [ {{*/*{ idx: 21, cn: '学生成功案例', en: 'Student Successes', submenus: [] },
                         { idx: 22, cn: '良好的语言环境', en: 'English Environment', submenus: [] },
                         { idx: 23, cn: '高素质队伍与优秀的课程设置', en: '', submenus: [] },
                         { idx: 24, cn: '升学', en: '', submenus: [] },
                         { idx: 25, cn: '学生后勤', en: 'Student logistics', submenus: [] },
                         { idx: 26, cn: '课余生活', en: '', submenus: [] }*/*}} ] },

           { idx: 3, cn: '课程安排', en: 'Courses',
             submenus: [ { idx: 31, cn: '语言预备课程', en: 'English language', submenus: [] },
                         { idx: 32, cn: '大学预科课程', en: 'Univeristy foundation', submenus: [] },
                         { idx: 33, cn: '国家管理学大专', en: 'National management diploma', submenus: [] },
                         { idx: 34, cn: '国家商科大专', en: 'National business diploma', submenus: [] },
                         { idx: 35, cn: '纽西兰商科大专', en: 'NZ business diploma', submenus: [] },
                         { idx: 36, cn: '游学', en: 'Visit study',
                           submenus: [ { idx: 361, cn: '关于纽西兰', en: 'About New Zealand', submenus: [] },
                                       { idx: 362, cn: '城市', en: 'City', submenus: [] },
                                       {{*/*{ idx: 363, cn: '寄宿家庭', en: 'Homestay', submenus: [] },*/*}}
                                       { idx: 364, cn: '课程安排', en: 'Visit study course', submenus: [] } ] } ] },

           { idx: 4, cn: '入学申请与费用', en: 'Facilities',
             submenus: [ { idx: 41, cn: '费用列表', en: 'Fees details', submenus: [] },
                         { idx: 42, cn: '入读协议', en: 'Terms and conditions', submenus: [] },
                         { idx: 43, cn: '在线咨询及申请', en: 'Online service', submenus: [] }{{*/*,
                         { idx: 44, cn: '如何申请', en: 'How to apply', submenus: [] } */*}}] },

           { idx: 5, cn: '所在地', en: 'Contact us',
             submenus: [ { idx: 51, cn: '地图', en: 'Map', submenus: [] },
                         { idx: 52, cn: '图片集', en: 'Photos', submenus: [] } ] },

           { idx: 6, cn: '学生服务', en: 'Student services',
             submenus: [ { idx: 61, cn: '行前手册', en: 'Student handbook', submenus: [] },
                         { idx: 62, cn: '生活在纽西兰', en: 'Living in New Zealand',
                           submenus: [ { idx: 621, cn: '购物', en: 'Shopping', submenus: [] },
                                       { idx: 622, cn: '交通', en: 'Transport', submenus: [] },
                                       { idx: 623, cn: '电话、互联网和邮件', en: 'Phone, internet and mail', submenus: [] },
                                       { idx: 624, cn: '资金和理财', en: 'Funds and finance', submenus: [] },
                                       { idx: 625, cn: '电器', en: 'Electrical devices', submenus: [] } ] },
                         { idx: 63, cn: '未满十八岁学生的监护', en: 'Minority protection law', submenus: [] },
                         { idx: 64, cn: '关爱与支持', en: 'Care and support', submenus: [] },
                         { idx: 65, cn: '住宿', en: 'Accommodation',
                           submenus: [ { idx: 651, cn: '寄宿家庭', en: 'Homestay', submenus: [] },
                                       { idx: 652, cn: '学生公寓', en: 'Student appartment', submenus: [] },
                                       { idx: 653, cn: '自租房', en: 'Flat', submenus: [] } ] } ] } ];

};